The Movie Toolbox provides a number of functions that allow your application to perform editing operations on tracks. These functions work with track segments--pieces of a track that are defined by a starting time and duration--and therefore give you a great deal of control over the editing process. These functions are similar to the low-level editing functions for movies that were described earlier in this chapter. However, these functions may copy movie data, if required by the operation.
When you edit a track you may change the duration of the movie that contains that track.
The CopyTrackSettings function lets you copy certain important settings from one track to another.
You can use the InsertTrackSegment function to copy a segment from one track to another. The InsertTrackEmptySegment function allows you to insert an empty segment into a track.
You can use the InsertMediaIntoTrack function to insert a media into a track.
Your application can delete a segment from a track by calling the DeleteTrackSegment function.
You can change a segment's duration by calling the ScaleTrackSegment function. This function stretches or shrinks the segment to accommodate a specified duration.
You can use the GetTrackEditRate function to determine the rate of the track edit of a specified track at an indicated time.
The InsertTrackSegment function copies part of one track to another. You specify the starting time and duration of the source segment and the time in the destination track at which to place the information.
pascal OSErr InsertTrackSegment (Track srcTrack, Track dstTrack,
TimeValue srcIn,
TimeValue srcDuration,
TimeValue dstIn);
The InsertTrackSegment function does not change the source track. However, the duration of the destination track is extended to accommodate the inserted segment. This may also change the duration of the movie that contains the destination track.
You can use this function to copy data within a single track. If you are not copying data from one location in a track to a different point in the same track, make sure that the two tracks are of the same type. For example, you cannot copy a segment from a sound track into a video track.
In addition, if the source and destination tracks are associated with different media data files, this function copies samples from the source to the destination using the AddMediaSample function. Therefore, the Movie Toolbox must be able to write to the destination media. In this case, your application must call the BeginMediaEdits function before calling InsertTrackSegment . At the end of the editing session, your application must call the EndMediaEdits function. See "Adding Samples to Media Structures," for more information about these functions.
If you have assigned a progress function to the movie that contains the destination track, the Movie Toolbox calls that progress function during long copy operations.
The InsertEmptyTrackSegment function adds an empty segment to a track. You specify the starting time and duration of the empty segment to be added. These times must be expressed in the movie's time scale. This function then inserts the appropriate amount of empty time into the track. The exact meaning of the term empty time depends upon the type of track. For example, empty time in a sound track is silent.
pascal OSErr InsertEmptyTrackSegment (Track dstTrack,
TimeValue dstIn,
TimeValue dstDuration);
The InsertMediaIntoTrack function inserts a reference to a media segment into a track. You specify the segment in the media by providing a starting time and duration. You specify the point in the destination track by providing a time in the track.
pascal OSErr InsertMediaIntoTrack (Track theTrack,
TimeValue trackStart,
TimeValue mediaTime,
TimeValue mediaDuration,
Fixed mediaRate);
The InsertMediaIntoTrack function inserts the media segment into the track at the specified location. The Movie Toolbox determines the duration of the segment in the track based on the media rate and duration information you provide.
You use this function after you have added samples to a media using the functions described in "Adding Samples to Media Structures," . If you play the track before you call this function, the track does not contain the new media data.
The DeleteTrackSegment function removes a specified segment from a track. You identify the segment to remove by specifying its starting time and duration.
pascal OSErr DeleteTrackSegment (Track theTrack,
TimeValue startTime, TimeValue duration);
To dispose of a track, call the DisposeMovieTrack function, described on DisposeMovieTrack .
The ScaleTrackSegment function changes the duration of a segment of a track. This may change the duration of the movie that contains the track. However, this function does not cause the Movie Toolbox to add data to or remove data from the movie.
pascal OSErr ScaleTrackSegment (Track theTrack,
TimeValue startTime,
TimeValue oldDuration,
TimeValue newDuration);
The CopyTrackSettings function copies many settings from one track to another, overwriting the destination settings.
pascal OSErr CopyTrackSettings (Track srcTrack, Track dstTrack);
The CopyTrackSettings function copies the
This function does not copy any alternate group information pertaining to the track.
If you want to work with specific characteristics, you can use the Movie Toolbox functions that allow you to manipulate track settings individually. These functions are described in "Functions That Modify Movie Properties," which begins on Functions That Modify Movie Properties .
This function does not copy the track's contents. To work with track contents, you should use the segment-editing functions described in "Editing Tracks," .
The GetTrackEditRate function returns the rate of the track edit of a specified track at an indicated time.
pascal Fixed GetTrackEditRate (Track theTrack, TimeValue atTime);
If an invalid time or track is passed, the returned value is 0.0. The track edit rate is typically 1.0, unless either the ScaleMovieSegment or ScaleTrackSegment function has been called. (For more on the ScaleMovieSegment and ScaleTrackSegment functions, see ScaleMovieSegment and ScaleTrackSegment , respectively.)
The GetTrackEditRate function is relevant if you are stepping through track edits directly in your application or if you are a client of the base media handler. (See Inside Macintosh: QuickTime Components for details on media handlers.)